from utils import ArgumentParser, ConfigLoader, LOG, set_logger_debug, path_validator

from cli import CliRunner

if __name__ == "__main__":
    argument_parser = ArgumentParser()
    args = argument_parser.parse_arguments()
    if args.debug:
        set_logger_debug()
    config_loader = ConfigLoader([
        "config.yaml",
        "config-secret.yaml"
    ])
    config = config_loader.load_config()

    for common_path in config["common-paths"].values():
        path_validator(common_path)

    if args.running_mode == "GUI":
        pass
    elif args.running_mode == "CLI":
        config.update({
            "use_zip": args.use_zip
        })
        if args.row_number:
            config.update({
                "row_number": args.row_number
            })
        runner = CliRunner(config = config)
        runner.run()
    else:
        LOG.error("Invalid running mode. Please choose between 'GUI' and 'CLI'.")
